# Maintainer: Diego Sogari <diego.sogari@falker.com.br>

_realname=glog
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.3.4.4d391fe
pkgrel=2
pkgdesc="C++ implementation of the Google logging module (mingw-w64)"
arch=('any')
url="https://github.com/google/glog"
license=('New BSD License')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-cmake")
depends=("${MINGW_PACKAGE_PREFIX}-gflags")
commit=4d391fe692ae6b9e0105f473945c415a3ce5a401
source=("${_realname}-${commit}.zip::https://codeload.github.com/google/glog/zip/${commit}"
        "${_realname}-${pkgver}.patch")
sha256sums=('aef60d6c6a6e334defcb56cbe5f007786a7fb6a7beb3da79ac02e6dfafa2807e'
            '154dafa6663b68a979c56ae4fae2a4f12513613ae0a84947a7a73565735d5691')

prepare() {
  cd "${srcdir}/${_realname}-${commit}"
  patch -Np1 -i "../${_realname}-${pkgver}.patch"
}

build() {
  rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DBUILD_SHARED_LIBS=YES \
    "../${_realname}-${commit}"

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make test
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
